package cn.flying.cloud.task.service.impl;

import java.io.Serializable;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import cn.flying.cloud.base.common.vo.PageRequest;
import cn.flying.cloud.base.common.vo.PageResponse;
import cn.flying.cloud.task.entity.TaskStepInfo;
import cn.flying.cloud.task.mapper.TaskStepInfoMapper;
import cn.flying.cloud.task.service.TaskStepInfoService;

/**
 * 批量任务step信息 服务实现类
 *
 * @author admin
 * @since 2025-01-24 09:31:45
 */
@Service
public class TaskStepInfoServiceImpl extends ServiceImpl<TaskStepInfoMapper, TaskStepInfo> implements TaskStepInfoService {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    /**
     * 查询总数
     *
     * @param taskStepInfo
     * @return
     */
    @Override
    public long countObj(TaskStepInfo taskStepInfo) {
        return this.count(getLambdaQueryWrapper(taskStepInfo));
    }

    /**
     * 分页查询批量任务step信息数据
     *
     * @param request
     * @return
     */
    @Override
    public PageResponse<TaskStepInfo> getPageList(PageRequest<TaskStepInfo> request) {
        TaskStepInfo param = request.getParam();
        LambdaQueryWrapper<TaskStepInfo> wrapper = getLambdaQueryWrapper(param);
        // wrapper TODO
        Page<TaskStepInfo> page = this.page(new Page<>(request.getPageNum(), request.getPageSize()), wrapper);
        return new PageResponse<>(page.getTotal(), (int) page.getCurrent(), page.getRecords());
    }

    /**
     * 构建查询对象
     *
     * @param param
     * @return
     */
    private LambdaQueryWrapper<TaskStepInfo> getLambdaQueryWrapper(TaskStepInfo param) {
        LambdaQueryWrapper<TaskStepInfo> wrapper = new LambdaQueryWrapper<>();
        // wrapper TODO
        return wrapper;
    }

    /**
     * 列表查询批量任务step信息数据
     *
     * @param taskStepInfo
     * @return
     */
    @Override
    public List<TaskStepInfo> getList(TaskStepInfo taskStepInfo) {
        LambdaQueryWrapper<TaskStepInfo> wrapper = new LambdaQueryWrapper<>();
        // wrapper TODO
        List<TaskStepInfo> list = this.list(wrapper);
        return list;
    }

    /**
     * 查询批量任务step信息详情数据
     *
     * @param taskStepInfo
     * @return
     */
    @Override
    public TaskStepInfo getOneObj(TaskStepInfo taskStepInfo) {
        LambdaQueryWrapper<TaskStepInfo> wrapper = new LambdaQueryWrapper<>();
        // wrapper TODO
        return this.getOne(wrapper);
    }

    /**
     * 根据Id查询批量任务step信息详情数据
     *
     * @param id
     * @return
     */
    @Override
    public TaskStepInfo getObjById(Serializable id) {
        return this.getById(id);
    }

    /**
     * 新增批量任务step信息数据
     *
     * @param taskStepInfo
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean createObj(TaskStepInfo taskStepInfo) {
        return this.save(taskStepInfo);
    }

    /**
     * 更新批量任务step信息数据
     *
     * @param taskStepInfo
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean updateObj(TaskStepInfo taskStepInfo) {
        return this.saveOrUpdate(taskStepInfo);
    }

    /**
     * 删除批量任务step信息数据
     *
     * @param taskStepInfo
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean deleteObj(TaskStepInfo taskStepInfo) {
        LambdaQueryWrapper<TaskStepInfo> wrapper = new LambdaQueryWrapper<>();
        // wrapper TODO
        return this.remove(wrapper);
    }

    /**
     * 根据Id删除批量任务step信息数据
     *
     * @param id
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean deleteById(Serializable id) {
        return this.removeById(id);
    }
}
